package basicCompiler;

import basicCompiler.visitor.TreeVisitable;


public abstract class Node implements TreeVisitable{
	
	protected Object value;
	protected Node leftChild, rightChild;
	
	public Node(){
		this.leftChild = null;
		this.rightChild = null;
	}
	
	public void setChildren(Node left, Node right){
		this.leftChild = left;
		this.rightChild = right;
	}	
	
	public void display(){
		Node node = this;
		StringBuffer tabs = new StringBuffer("\t");
		
		while ( node != null){
			System.out.println(tabs.toString() + node);
			if (node.rightChild != null){
				tabs.append("\t");
				System.out.println(tabs.toString() + node.leftChild);
			}
			node = node.rightChild;
		}
	}

	public String toString(){
		return value.toString();
	}
}

